﻿CREATE VIEW [dbo].[ASMS_V_PackagePurchaseBill]
	AS 
SELECT PPB.*,
	C.Name as CustomerName, 
	C.Telephone as CustomerTelephone,
	P.Name as PackageName,
	P.Code as PackageCode,
	S.Name as SalesManagerName,
	P.SalesCommission as SalesCommission,
	P.SalesCommissionType as SalesCommissionType,
	P.ExpiringDate as PackageExpiringDate,
	P.MarketPrice as PackageMarketPrice,
	MDISP.Name as BoughtChannelName
FROM [ASMS_PackagePurchaseBill] as PPB
	left join ASMS_Customer as C on C.Id = PPB.CustomerId
	left join ASMS_Package as P on P.Id = PPB.PackageId
	left join ASMS_Staff as S on S.Id = PPB.SalesManagerId
	left join ASMS_MasterDataItem as MDISP on MDISP.Code = PPB.BoughtChannel
